function AnimateOrbit(t,R,UTC,dt)
    
    Re = 6378.136;
    %[km]Mean equatorial radius of the Earth.
    
    tnew = 0:dt:ceil(max(t));
    %[s]New time vector.
    
    Rnew = [interp1(t,R(1,:),tnew); ...
            interp1(t,R(2,:),tnew); ...
            interp1(t,R(3,:),tnew)];
    %[km]New position matrix.
    
    Rnew = Rnew / Re;
    %[Earth radii]Converts the position matrix from kilometers to Earth radii.
    
    n = numel(tnew);
    %[]Number of elements in the new time vector.
    
    r = zeros(1,n);
    %[]Allocates memory for the range vector.
    
    for k = 1:n;
        
        r(k) = norm(Rnew(:,k));
        %[Earth radii]Current range.
        
    end
    
    Extent = ceil(max(r));
    %[]Axes extents.
    
    JD = juliandate(UTC) + tnew / 3600 / 24;
    %[solar days]Julian date vector.
        
    Tu = juliandate(UTC) - 2451545 + tnew / 3600 / 24;
    %[solar days]Solar days between the initial universal time and January 1, 2000 at noon.
    
    ERA = 2 * pi * (0.7790572732640 + 1.00273781191135448 * Tu) * 180 / pi;
    %[deg]Earth rotation angles for all simulation times.
    
    [xe,ye,ze] = ellipsoid(0,0,0,1,1,1,50);
    %[Earth radii]Determines the coordinates of the Earth.
    
    Earth = imread('Earth.bmp');
    %[]Loads the image of the Earth.
    
    ScreenSize = get(0,'ScreenSize');
    %[]Determines the location and dimensions of the current monitor.
    
    Window = figure( ...
        'Color','k', ...
        'MenuBar','None', ...
        'Name','ORBIT ANIMATION IN THREE DIMENSTIONS', ...
        'NumberTitle','Off', ...
        'OuterPosition',ScreenSize, ...
        'Resize','Off', ...
        'ToolBar','None');
    %[]Opens a new window and adjusts its properties.
    
    Axes = axes( ...
        'CameraPosition',Extent*[1,1,1], ...
        'CameraTarget',[0,0,0], ...
        'Color','k', ...
        'Parent',Window, ...
        'PlotBoxAspectRatio',[1,1,1], ...
        'NextPlot','Add', ...
        'XColor','k', ...
        'YColor','k', ...
        'ZColor','k', ...
        'XLim',Extent * [-1,1], ...
        'YLim',Extent * [-1,1], ...
        'ZLim',Extent * [-1,1]);
    %[]Adds an axes to the specified window and adjusts its properties.
    
    for k = 1:n
        
        cla(Axes);
        %[]Clears all plots from the specified axes.
        
        Surface = surface(xe,ye,-ze, ...
            'CData',Earth, ...
            'EdgeColor','None', ...
            'FaceColor','TextureMap', ...
            'Parent',Axes);
        %[]Adds a plot to the specified axes and adjusts its properties.
        
        rotate(Surface,[0,0,1],ERA(k),[0,0,0]);
        %[]Rotates the Earth about the K-axis by the current Earth rotation angle.
        
        plot3([0,Extent],[0,0],[0,0], ...
            'Color','r', ...
            'LineStyle','-', ...
            'LineWidth',3, ...
            'Marker','None', ...
            'Parent',Axes);
        %[]Adds a plot to the specified window and adjusts its properties.
        
        plot3([0,0],[0,Extent],[0,0], ...
            'Color','r', ...
            'LineStyle','-', ...
            'LineWidth',3, ...
            'Marker','None', ...
            'Parent',Axes);
        %[]Adds a plot to the specified window and adjusts its properties.
        
        plot3([0,0],[0,0],[0,Extent], ...
            'Color','r', ...
            'LineStyle','-', ...
            'LineWidth',3, ...
            'Marker','None', ...
            'Parent',Axes);
        %[]Adds a plot to the specified window and adjusts its properties.
        
        plot3(Rnew(1,1:k),Rnew(2,1:k),Rnew(3,1:k), ...
            'Color','w', ...
            'LineStyle','None', ...
            'Marker','.', ...
            'Parent',Axes);
        %[]Adds a plot to the specified axes and adjusts its properties.
        
        plot3(Rnew(1,k),Rnew(2,k),Rnew(3,k), ...
            'Color','y', ...
            'LineStyle','None', ...
            'Marker','.', ...
            'MarkerSize',35, ...
            'Parent',Axes);
        %[]Adds a plot to the specified axes and adjusts its properties.
        
        text( ...
            'BackGroundColor','k', ...
            'Color','y', ...
            'FontName','Arial', ...
            'FontSize',12, ...
            'FontWeight','Bold', ...
            'HorizontalAlignment','Center', ...
            'LineStyle','None', ...
            'Parent',Axes, ...
            'Position',[Extent,0,0], ...
            'String','X', ...
            'VerticalAlignment','Middle');
        %[]Adds a text box to the specified axes and adjusts its properties.
        
        text( ...
            'BackGroundColor','k', ...
            'Color','y', ...
            'FontName','Arial', ...
            'FontSize',12, ...
            'FontWeight','Bold', ...
            'HorizontalAlignment','Center', ...
            'LineStyle','None', ...
            'Parent',Axes, ...
            'Position',[0,Extent,0], ...
            'String','Y', ...
            'VerticalAlignment','Middle');
        %[]Adds a text box to the specified axes and adjusts its properties.
        
        text( ...
            'BackGroundColor','k', ...
            'Color','y', ...
            'FontName','Arial', ...
            'FontSize',12, ...
            'FontWeight','Bold', ...
            'HorizontalAlignment','Center', ...
            'LineStyle','None', ...
            'Parent',Axes, ...
            'Position',[0,0,Extent], ...
            'String','Z', ...
            'VerticalAlignment','Middle');
        %[]Adds a text box to the specified axes and adjusts its properties.
        
        CD = CalendarDate(JD(k));
        %[year,month,day,hour,minute,second]Current calendar date.
        
        String1 = sprintf('Julian Date = %0.8f',JD(k));
        %[]z-displacement string.
        
        String2 = sprintf('Calendar Date = %4.0f:%02.0f:%02.0f:%02.0f:%02.0f:%02.0f',CD);
        %[]Calendar date string.
        
        String = char(String1,String2);
        %[]Combined string.
        
        text( ...
            'BackGroundColor','k', ...
            'Color','y', ...
            'FontName','Arial', ...
            'FontSize',12, ...
            'FontWeight','Bold', ...
            'HorizontalAlignment','Center', ...
            'LineStyle','None', ...
            'Parent',Axes, ...
            'Position',[Extent,Extent,-Extent], ...
            'String',String, ...
            'VerticalAlignment','Middle');
        %[]Adds a text box to the specified axes and adjusts its properties.
        
        pause(0.001);
        %[]Pauses the animation for the specified amount of time.
        
    end
    
    title( ...
        'Simulation Complete!', ...
        'Color','y', ...
        'FontSize',20, ...
        'FontWeight','Bold', ...
        'Parent',Axes);
    %[]Adds a title to the specified axes and adjusts its properties.
    
end
%===================================================================================================